package leetcode_1_200;

import java.util.Arrays;

public class LeeCode_04 {
    public static void main(String[] args) {

    }
    private static double findMedianSortedArrays(int[] nums1, int[] nums2) {
        int n1 = nums1.length;
        int n2 = nums2.length;
        int[] nums = new int[n1 + n2];
        for (int i = 0; i < n1; i++) {
            nums[i] = nums1[i];
        }
        for (int i = n1; i < n1 + n2; i++) {
            nums[i] = nums2[i - n1];
        }
        Arrays.sort(nums);
        int l = 0,r= nums.length - 1;
        while (l < r){
            l++;
            r--;
        }
        if (l == r)
            return nums[l];
        return ((double) nums[l] + nums[r]) / 2;
    }
}
